package com.seeyou.lake.widget

import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.util.DisplayMetrics
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.Button
import android.widget.EditText
import android.widget.ImageView
import android.widget.ScrollView
import android.widget.TextView
import com.seeyou.lake.R

class LoginOutDialog(context: Context) : Dialog(context, R.style.MyTheme_Dialog) {

    private var positiveButton: Button? = null
    private var negativeButton: ImageView? = null


    init {
        // 设置Dialog的布局
        val view = LayoutInflater.from(context).inflate(R.layout.dialog_tip_loginout, null)
        setContentView(view)

        // 设置Dialog的宽度和高度
        window?.setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
        // 设置Dialog的位置为屏幕中心
        window?.attributes?.gravity = Gravity.CENTER
        window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))

        setCancelable(false)
        setCanceledOnTouchOutside(false)
        positiveButton = view.findViewById(R.id.btn_dialog_submit)
        negativeButton = view.findViewById(R.id.iv_dialog_close)
        negativeButton?.setOnClickListener { dismiss() }
    }

    fun setPositiveButton(listener: (() -> Unit)?): LoginOutDialog {
        positiveButton?.setOnClickListener {
            listener?.invoke()
            dismiss()
        }
        return this
    }

}